package org.luxor.commons.storage.constant;

import org.luxor.commons.storage.exception.StorageTypeNotSupportedException;

/**
 * 存储类型
 *
 * @author YanXinMing @date 2024/8/28
 */
public enum StorageType {
    // 0：本地磁盘 1：Minio 2：FastDfs 3：七牛  4：阿里云  5：腾讯云
    DISK(0),
    MINIO(1),
    FAST_DFS(2),
    QINIU(3),
    ALIYUN(4),
    QCLOUD(5);

    private final int code;

    StorageType(int code) {
        this.code = code;
    }

    public int getCode() {
        return code;
    }

    public static StorageType valueOf(Integer code) {
        for (StorageType storageType : StorageType.values()) {
            if (storageType.code == code) {
                return storageType;
            }
        }
        throw new StorageTypeNotSupportedException("存储类型(storageType)参数错误,不存在该存储类型");
    }

    @Override
    public String toString() {
        return "StorageType{" +
                "code=" + code +
                '}';
    }
}
